package com.haiheng.library_base.db

import androidx.room.*

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2022/5/25 0025
 * @Version: 1.0
 */
@Dao
interface SmartEploymentRecordDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(recordTable: SmartEploymentRecordTable): Long

    @Delete
    suspend fun delete(recordTable: SmartEploymentRecordTable): Int
    @Delete
    suspend fun deleteList(recordTableList : List<SmartEploymentRecordTable>)
    @Update
    suspend fun update(recordTable: SmartEploymentRecordTable): Int

    @Query("SELECT * FROM start_eploymen_record_table")
    suspend fun queryAll():  List<SmartEploymentRecordTable>

    @Query("SELECT * FROM start_eploymen_record_table WHERE `status` = :status ORDER BY id DESC LIMIT 1")
    suspend fun findByKey(status: Int): SmartEploymentRecordTable?

    @Query("SELECT COUNT(id) FROM start_eploymen_record_table WHERE  `status` = :status AND  `recordType` = :recordType AND createDate BETWEEN :start AND :end")
    fun queryTodayCount(recordType : String,status: Int,start:Long,end:Long):Int

    @Query("SELECT COUNT(id) FROM start_eploymen_record_table WHERE `recordType` = :recordType AND createDate BETWEEN :start AND :end")
    fun queryTodayTotalCount(recordType : String,start:Long,end:Long):Int
}